<%@page import="pl.org.waff.WaffServlet"%>
<%@page import="pl.org.waff.PathElement"%>
<%@page import="java.util.ArrayList"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<jsp:useBean id="sitenavigator" class="pl.org.waff.DefaultNavigator" scope="application" />
<jsp:useBean id="applicationprefix" class="java.lang.String" scope="application" />
<b>You are here:</b>&nbsp;
<%
    String currentPath = WaffServlet.getCurrentPath((String) request.getAttribute(WaffServlet.PATH_ATTRIBUTE_NAME));
    String rootPath = (String) request.getSession().getAttribute(WaffServlet.PATH_PREFIX_ATTRIBUTE_NAME);
    if (rootPath == null) {
        rootPath = "";
    } else if (rootPath.endsWith("/")) {
        rootPath = rootPath.substring(0, rootPath.length() - 1);
    }
    if (sitenavigator != null) {
        PathElement pe = sitenavigator.getPathData(currentPath, (String) request.getSession().getAttribute(WaffServlet.PATH_PREFIX_ATTRIBUTE_NAME));
        if (pe != null) {
            ArrayList pNames = pe.getElements();
            ArrayList pPaths = pe.getElementPaths();
            String name;
            String link;
            for (int i = 0; i < pNames.size(); i++) {
                name = (String) pNames.get(i);
                link = (String) pPaths.get(i);
                out.print("<a href=\"" + applicationprefix + rootPath+link + "\">" + name + "</a>");
                out.print("&gt;");
            }
        }
    }
%>
